#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i) 
#define mkp std::make_pair
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;
inline bool cmp(int x,int y){return x < y;}
const int inf = 1e9+9;
const int N = 1e6+9;
const double eps = 1e-7;
int _,n,m,a[2*N],u,v;
string str;

//----------------------------

int head[2*N],next[2*N],ver[2*N],tot;

inline void link(int x,int y){ver[++tot] = y , next[tot] = head[x] , head[x] = tot;}

//----------------------------

int fa[2*N],top[2*N],son[2*N],size[2*N],deep[2*N],id[2*N],b[2*N];

inline void dfs1(int now,int fathter){
    fa[now] = fathter , deep[now] = deep[fathter] + 1 , size[now] = 1;
    for(int i = head[now];i;i = next[i]){
        if(ver[i] == fathter) continue;
        dfs1(ver[i],now);
        size[now] += size[ ver[i] ];
        son[now] = size[ son[now] ] > size[ son[ver[i]] ] ? son[now] : ver[i];
    }
    return;
}

inline void dfs2(int now,int toper){
    id[now] = ++id[0] , b[ id[0] ] = a[now] , top[now] = toper;
    if(!son[now]) return;
    dfs2(son[now],toper);
    for(int i = head[now];i;i = next[i]){
        if(id[ ver[i] ]) continue;
        dfs2(ver[i],ver[i]);
    }
    return;
}

//----------------------------

int TOT;
struct node{
    int l,r,sum,max;
    node * ls , * rs;
}Tree[4*N];

inline node * create(){return &Tree[++TOT];}

inline void pushup(node * cur){cur->sum = cur->ls->sum + cur->rs->sum , cur->max = std::max(cur->ls->max,cur->rs->max);}

inline void build(node * cur,int l,int r){
    cur->l = l , cur->r = r , cur->sum = cur->max = 0;
    if(l == r){
        cur->sum = cur->max = b[l];
        return;
    }
    int mid = (l+r) >> 1;
    cur->ls = create() , cur->rs = create();
    build(cur->ls,l,mid) , build(cur->rs,mid+1,r);
    pushup(cur);
    return;
}

inline void edit(node * cur){
    if(cur->l == cur->r){
        cur->sum = cur->max = v;
        return;
    }
    if(u <= cur->ls->r) edit(cur->ls);
    if(cur->rs->l <= u) edit(cur->rs);
    pushup(cur);
    return;
}

inline int query_max(node * cur){
    if(cur->r < u || v < cur->l) return -inf;
    if(u <= cur->l && cur->r <= v) return cur->max;
    return std::max(query_max(cur->ls),query_max(cur->rs));
}

inline int query_sum(node * cur){
    if(cur->r < u || v < cur->l) return 0;
    if(u <= cur->l && cur->r <= v) return cur->sum;
    return query_sum(cur->ls) + query_sum(cur->rs);
}

//----------------------------

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("in.in", "r", stdin);
    cin >> n;
    rep(i,1,n-1){
        cin >> u >> v;
        link(u,v) , link(v,u);
    }
    rep(i,1,n) cin >> a[i];
    
    //----------------------------
    
    dfs1(1,1) , dfs2(1,1);
    node * root = create();
    build(root,1,n);

    //----------------------------

    cin >> m;
    while(m--){
        cin >> str >> u >> v;
        if(str == "CHANGE"){
            u = id[u];
            edit(root);
        } else if(str == "QMAX"){
            int x = u , y = v , ans = -inf;
            while(top[x] != top[y]){
                if(deep[ top[x] ] < deep[ top[y] ]) std::swap(x,y);
                u = id[ top[x] ] , v = id[x] , x = fa[ top[x] ] , ans = std::max(ans,query_max(root));
            }
            if(id[x] > id[y]) std::swap(x,y);
            u = id[x] , v = id[y] , ans = std::max(ans,query_max(root));
            cout << ans << "\n";
        } else if(str == "QSUM"){
            int x = u , y = v , ans = 0;
            while(top[x] != top[y]){
                if(deep[ top[x] ] < deep[ top[y] ]) std::swap(x,y);
                u = id[ top[x] ] , v = id[x] , x = fa[ top[x] ] , ans += query_sum(root);
            }
            if(id[x] > id[y]) std::swap(x,y);
            u = id[x] , v = id[y] , ans += query_sum(root);
            cout << ans << "\n";
        }
    }
    return 0;
}